//try and replicate figure 17 in Seshadri and Lee (2018)
use "$data/Lee_Seshadri/cds_panel", clear

//generate acitve/passive time from mom and dad
gen dad_time1 = .
gen dad_time2 = .
gen mom_time1 = .
gen mom_time2 = .

replace dad_time1 = headtime if head_sex == 1
replace dad_time2 = headtime2 if head_sex == 1

replace mom_time1 = wifetime if head_sex == 1
replace mom_time2 = wifetime2 if head_sex == 1

replace mom_time1 = headtime if head_sex == 2
replace mom_time2 = headtime2 if head_sex == 2

su dad_time1 [w = cds_weight]
su mom_time1 [w = cds_weight]

//correlation between head/wife time and hours investments
gen head_wage = head_labinc / (head_annual)
gen wife_wage = wife_labinc / (wife_annual)

corr head_wage dad_time1
corr wife_wage mom_time1


//average inputs
gen total_time = .
replace total_time = mom_time1 if mom_time1!=. & dad_time1 == .
replace total_time = dad_time1 if dad_time1!=. & mom_time1 == .
replace total_time = (dad_time1 + mom_time1)/2 if mom_time1!=. & dad_time1!=.
replace total_time = total_time / 168
su total_time [w = cds_weight] //more or less a replication
//local time = `r(mean)'

//study differences based on marreid vs non=married
replace total_time = mom_time1 + dad_time1 if mom_time1!=. & dad_time1!=. //now the sum instead of average input
replace total_time = total_time / 168 if mom_time1!=. & dad_time1!=.
su total_time [w = cds_weight] //more or less a replication
local time = `r(mean)'

//marriage dummy
gen married = 1
replace married = 0 if wife_age ==0

su total_time if married [w = cds_weight]
su total_time if !married [w = cds_weight]

replace total_time = total_time/2 if married

su total_time if married
su total_time if !married


//add to moments data and export
use "$temp/moments_withmig", clear
count 
local new = `r(N)' + 1
set obs `new'
local line1 = `r(N)' + 1
replace moment = `time' in `line1'
save "$temp/moments_withtime", replace
//export delimited "$model/moments/moments.csv", novarn replace

 
//end of dofile